/*============================================================================*/
/*  Copyright (C) 2009-2011,  INFRASTRUCTURE SOFTWARE CO.,LTD.
 *
 *  All rights reserved. This software is  property. Duplication
 *  or disclosure without  written authorization is prohibited.
 *
 *  @file        <DcmDsl_SessionManage.c>
 *  @brief       <>
 *
 *  <Compiler: CodeWarrior    MCU:XXX>
 *
 *  @author     <shushi>
 *  @date       <2018-3-20>
 */
/*============================================================================*/
/*=======[R E V I S I O N   H I S T O R Y]====================================*
*  <VERSION>    <DATE>       <AUTHOR>    <REVISION LOG>
*  V1.0.0       2018-3-20    shushi      Initial version
*  V1.0.1       2019-12-24   tao.yu      QAC check fix
*  V1.0.2       2020-1-7     tao.yu      Commercial project problem modification
============================================================================*/

/*=======[V E R S I O N  I N F O R M A T I O N]===============================*/
#define DCMDSL_SESSIONMANAGE_C_AR_MAJOR_VERSION  4
#define DCMDSL_SESSIONMANAGE_C_AR_MINOR_VERSION  2
#define DCMDSL_SESSIONMANAGE_C_AR_PATCH_VERSION  2
#define DCMDSL_SESSIONMANAGE_C_SW_MAJOR_VERSION  1
#define DCMDSL_SESSIONMANAGE_C_SW_MINOR_VERSION  0
#define DCMDSL_SESSIONMANAGE_C_SW_PATCH_VERSION  2

/******************************* references ************************************/
#include "Dcm_Include.h"
#if(BSWM_DCM_ENABLE == STD_ON)
#include "BswM_Dcm.h"
#endif
#include "UDS.h"

#if(STD_ON == DCM_SESSION_FUNC_ENABLED)
/*=======[V E R S I O N  C H E C K]===========================================*/
#if (DCMDSL_SESSIONMANAGE_C_AR_MAJOR_VERSION != DCMDSL_SESSIONMANAGE_H_AR_MAJOR_VERSION)
  #error "DcmDsl_SessionManage.c : Mismatch in Specification Major Version"
#endif
#if (DCMDSL_SESSIONMANAGE_C_AR_MINOR_VERSION != DCMDSL_SESSIONMANAGE_H_AR_MINOR_VERSION)
  #error "DcmDsl_SessionManage.c : Mismatch in Specification Major Version"
#endif
#if (DCMDSL_SESSIONMANAGE_C_AR_PATCH_VERSION != DCMDSL_SESSIONMANAGE_H_AR_PATCH_VERSION)
  #error "DcmDsl_SessionManage.c : Mismatch in Specification Major Version"
#endif
#if (DCMDSL_SESSIONMANAGE_C_SW_MAJOR_VERSION != DCMDSL_SESSIONMANAGE_H_SW_MAJOR_VERSION)
  #error "DcmDsl_SessionManage.c : Mismatch in Specification Major Version"
#endif
#if (DCMDSL_SESSIONMANAGE_C_SW_MINOR_VERSION != DCMDSL_SESSIONMANAGE_H_SW_MINOR_VERSION)
  #error "DcmDsl_SessionManage.c : Mismatch in Specification Major Version"
#endif
#if (DCMDSL_SESSIONMANAGE_C_SW_PATCH_VERSION != DCMDSL_SESSIONMANAGE_H_SW_PATCH_VERSION)
  #error "DcmDsl_SessionManage.c : Mismatch in Specification Major Version"
#endif

/********************************************************/
#define  DCM_START_SEC_CODE
#include "Dcm_MemMap.h"
static FUNC(void,DCM_CODE)DslInternal_SetSesCtrlType(Dcm_SesCtrlType NewSes);
#define  DCM_STOP_SEC_CODE
#include "Dcm_MemMap.h"

/*****************************/
#define  DCM_START_SEC_CODE
#include "Dcm_MemMap.h"
static FUNC(Std_ReturnType,DCM_CODE)DslInternal_GetSesTimingValues(Dcm_SesCtrlType NewSes,
																   P2VAR(uint32,AUTOMATIC,DCM_VAR)P2ServerTimer,
																   P2VAR(uint32,AUTOMATIC,DCM_VAR)P2StarServerTimer);
#define  DCM_STOP_SEC_CODE
#include "Dcm_MemMap.h"

/*****************************/
#define  DCM_START_SEC_CODE
#include "Dcm_MemMap.h"
static FUNC(void,DCM_CODE)DslInternal_SetSesTimingValues(Dcm_SesCtrlType NewSes);
#define  DCM_STOP_SEC_CODE
#include "Dcm_MemMap.h"

/*****************************/
#define  DCM_START_SEC_CODE
#include "Dcm_MemMap.h"
static FUNC(void,DCM_CODE)DslInternal_DefaultToDefault(Dcm_SesCtrlType NewSes);
#define  DCM_STOP_SEC_CODE
#include "Dcm_MemMap.h"

/*****************************/
#define  DCM_START_SEC_CODE
#include "Dcm_MemMap.h"
static FUNC(void,DCM_CODE)DslInternal_DefaultToUndefault(Dcm_SesCtrlType NewSes);
#define  DCM_STOP_SEC_CODE
#include "Dcm_MemMap.h"

/*****************************/
#define  DCM_START_SEC_CODE
#include "Dcm_MemMap.h"
static FUNC(void,DCM_CODE)DslInternal_UndefaultToUndefault(Dcm_SesCtrlType NewSes);
#define  DCM_STOP_SEC_CODE
#include "Dcm_MemMap.h"

/*****************************/
#define  DCM_START_SEC_CODE
#include "Dcm_MemMap.h"
static FUNC(void,DCM_CODE)DslInternal_UndefaultTodefault(Dcm_SesCtrlType NewSes);
#define  DCM_STOP_SEC_CODE
#include "Dcm_MemMap.h"

/*****************************/
#define  DCM_START_SEC_CODE
#include "Dcm_MemMap.h"
static FUNC(void,DCM_CODE)DslInternal_SesTranslation(Dcm_SesCtrlType NewSes);
#define  DCM_STOP_SEC_CODE
#include "Dcm_MemMap.h"

/********************************************************
 **********************resource define*******************
********************************************************/
#define  DCM_START_SEC_VAR_NOINIT_UNSPECIFIED
#include "Dcm_MemMap.h"
VAR(Dcm_SesCtrlCBType,DCM_VAR_NOINIT) Dcm_SesCtrl;/*Session management control block*/
#define  DCM_STOP_SEC_VAR_NOINIT_UNSPECIFIED
#include "Dcm_MemMap.h"

/*************************************************************************/
/*
 * Brief               <The initialization of session management control block>
 * ServiceId           <None>
 * Sync/Async          <Synchronous>
 * Reentrancy          <Reentrant>
 * Param-Name[in]      <None>
 * Param-Name[out]     <None>
 * Param-Name[in/out]  <None>
 * Return              <None>
 * PreCondition        <>
 * CallByAPI           <APIName>
 */
/*************************************************************************/
#define  DCM_START_SEC_CODE
#include "Dcm_MemMap.h"
FUNC(void,DCM_CODE) DslInternal_InitSesCtrl(void)
{
    SchM_Enter_Dcm(Dcm_SesCtrl);
    /****@req DCM-FUNR-033[DCM034]****/
    Dcm_SesCtrl.Dcm_ActiveSes = DCM_DEFAULT_SESSION;
    Dcm_SesCtrl.Dcm_NewSes    = DCM_DEFAULT_SESSION;
    Dcm_SesCtrl.Dcm_S3Ctrl.Dcm_S3CurTimer     = DCM_INVALID_UINT32;
    Dcm_SesCtrl.Dcm_S3Ctrl.Dcm_S3ExpiredTimer = DCM_INVALID_UINT32;
    Dcm_SesCtrl.Dcm_S3Ctrl.Dcm_S3State        = DCM_S3TIMER_OFF;
    Dcm_SesCtrl.Dcm_SessionState = DCM_SESSION_DEFAULT;
    SchM_Exit_Dcm(Dcm_SesCtrl);
}
#define  DCM_STOP_SEC_CODE
#include "Dcm_MemMap.h"

/*************************************************************************/
/*
 * Brief               <start S3Timer>
 * ServiceId           <None>
 * Sync/Async          <Synchronous>
 * Reentrancy          <Reentrant>
 * Param-Name[in]      <None>
 * Param-Name[out]     <None>
 * Param-Name[in/out]  <None>
 * Return              <None>
 * PreCondition        <>
 * CallByAPI           <APIName>
 */
/*************************************************************************/
#define  DCM_START_SEC_CODE
#include "Dcm_MemMap.h"
FUNC(void,DCM_CODE) DslInternal_S3ServerStart(void)
{
    SchM_Enter_Dcm(Dcm_SesCtrl);
    Dcm_SesCtrl.Dcm_S3Ctrl.Dcm_S3CurTimer     = Frt_ReadOutMS();
    Dcm_SesCtrl.Dcm_S3Ctrl.Dcm_S3ExpiredTimer = 5000UL; /* ms converted to tick */
    Dcm_SesCtrl.Dcm_S3Ctrl.Dcm_S3State        = DCM_S3TIMER_ON;
    SchM_Exit_Dcm(Dcm_SesCtrl);
}
#define  DCM_STOP_SEC_CODE
#include "Dcm_MemMap.h"

/*************************************************************************/
/*
 * Brief               <stop S3Timer>
 * ServiceId           <None>
 * Sync/Async          <Synchronous>
 * Reentrancy          <Reentrant>
 * Param-Name[in]      <None>
 * Param-Name[out]     <None>
 * Param-Name[in/out]  <None>
 * Return              <None>
 * PreCondition        <>
 * CallByAPI           <APIName>
 */
/*************************************************************************/
#define  DCM_START_SEC_CODE
#include "Dcm_MemMap.h"
FUNC(void,DCM_CODE)DslInternal_S3ServerStop(void)
{
    SchM_Enter_Dcm(Dcm_SesCtrl);
    Dcm_SesCtrl.Dcm_S3Ctrl.Dcm_S3State = DCM_S3TIMER_OFF;
    SchM_Exit_Dcm(Dcm_SesCtrl);
}
#define  DCM_STOP_SEC_CODE
#include "Dcm_MemMap.h"

/*************************************************************************/
/*
 * Brief               <timeout of S3Timer>
 * ServiceId           <None>
 * Sync/Async          <Synchronous>
 * Reentrancy          <Reentrant>
 * Param-Name[in]      <None>
 * Param-Name[out]     <None>
 * Param-Name[in/out]  <None>
 * Return              <None>
 * PreCondition        <None>
 * CallByAPI           <APIName>
 */
/*************************************************************************/
#define  DCM_START_SEC_CODE
#include "Dcm_MemMap.h"
FUNC(void,DCM_CODE)DslInternal_S3ServerTimeout(void)
{
    SchM_Enter_Dcm(Dcm_SesCtrl);
    Dcm_SesCtrl.Dcm_NewSes = DCM_DEFAULT_SESSION;
    SchM_Exit_Dcm(Dcm_SesCtrl);
    /****@req DCM-FUNR-034[DCM140]****/
    DslInternal_SesRefresh(Dcm_SesCtrl.Dcm_NewSes);
    /***stop S3Timer***/
    DslInternal_S3ServerStop();
}
#define  DCM_STOP_SEC_CODE
#include "Dcm_MemMap.h"

/*************************************************************************/
/*
 * Brief               <Refresh session>
 * ServiceId           <None>
 * Sync/Async          <Synchronous>
 * Reentrancy          <Reentrant>
 * Param-Name[in]      <NewSes:Session control state to be refreshed>
 * Param-Name[out]     <None>
 * Param-Name[in/out]  <None>
 * Return              <None>
 * PreCondition        <None>
 * CallByAPI           <APIName>
 */
/*************************************************************************/
#define  DCM_START_SEC_CODE
#include "Dcm_MemMap.h"
FUNC(void,DCM_CODE)DslInternal_SesRefresh(Dcm_SesCtrlType NewSes)
{
      DslInternal_SesTranslation(NewSes);
#if(STD_ON == DCM_UDS_SERVICE0X2A_ENABLED)
      /*check 2A is supported in NewSes*/
      Dcm_UDS0x2ACheckNewSession(NewSes);
#endif
#if (DCM_DSP_DID_FOR_2F_NUM > 0)
      /*check 2F is supported in NewSes*/
      Dcm_UDS0x2FCheckNewSession(NewSes);
#endif
}
#define  DCM_STOP_SEC_CODE
#include "Dcm_MemMap.h"
/************************internal functions*****************************/
/*************************************************************************/
/*
 * Brief               <Set the session control state>
 * ServiceId           <None>
 * Sync/Async          <Synchronous>
 * Reentrancy          <Reentrant>
 * Param-Name[in]      <NewSes:the Latest session status>
 * Param-Name[out]     <None>
 * Param-Name[in/out]  <None>
 * Return              <None>
 * PreCondition        <None>
 * CallByAPI           <APIName>
 */
/*************************************************************************/
#define  DCM_START_SEC_CODE
#include "Dcm_MemMap.h"
static FUNC(void,DCM_CODE)DslInternal_SetSesCtrlType(Dcm_SesCtrlType NewSes)
{
    SchM_Enter_Dcm(Dcm_SesCtrl);
    Dcm_SesCtrl.Dcm_ActiveSes = NewSes;
    SchM_Exit_Dcm(Dcm_SesCtrl);

    SchM_Enter_Dcm(Dcm_MkCtrl);
    Dcm_MkCtrl.Dcm_ActiveSes  = NewSes;
    SchM_Exit_Dcm(Dcm_MkCtrl);
}
#define  DCM_STOP_SEC_CODE
#include "Dcm_MemMap.h"
/*************************************************************************/
/*
 * Brief               <The set NewSes corresponding configuration session time parameters>
 * ServiceId           <None>
 * Sync/Async          <Synchronous>
 * Reentrancy          <Reentrant>
 * Param-Name[in]      <NewSes:the Latest session status>
 * Param-Name[out]     <(*P2ServerTimer):P2ServerTimer which corresponding to NewSes
 *                      (*P2StarServerTimer):P2StarServerTimer which corresponding to NewSes>
 * Param-Name[in/out]  <None>
 * Return              <Std_ReturnType>
 * PreCondition        <None>
 * CallByAPI           <APIName>
 */
/*************************************************************************/
#define  DCM_START_SEC_CODE
#include "Dcm_MemMap.h"
static FUNC(Std_ReturnType,DCM_CODE)DslInternal_GetSesTimingValues(Dcm_SesCtrlType NewSes,
																   P2VAR(uint32,AUTOMATIC,DCM_VAR)P2ServerTimer,
																   P2VAR(uint32,AUTOMATIC,DCM_VAR)P2StarServerTimer)
{
   uint8    Number;
   uint8    Index;
   boolean  Flag;
   P2CONST(Dcm_DspSessionRowType,AUTOMATIC,DCM_CONST)pDspSessionRow;

   if(  (NULL_PTR == P2ServerTimer)
      ||(NULL_PTR == P2StarServerTimer))
   {
       return E_NOT_OK;
   }

   pDspSessionRow = (Dcm_DspCfg.pDcm_DspSession)->pDcmDspSessionRow;
   Number  	= (Dcm_DspCfg.pDcm_DspSession)->DcmDspSessionRow_Num;
   Flag 	= FALSE;
   for(Index=0;(Index<Number)&&(FALSE==Flag);Index++)
   {
       if(NewSes == (pDspSessionRow[Index].DcmDspSessionLevel))
       {
           Flag = TRUE;
       }
   }
   if(FALSE == Flag)
   {
       /*do not configured DcmDspSessionRow container ,or  do not find the corresponding NewSes in DcmDspSessionRows*/
       return E_NOT_OK;
   }
   (*P2ServerTimer)     = (uint32)pDspSessionRow[Index-1u].DcmDspSessionP2ServerMax;
   (*P2StarServerTimer) = (uint32)pDspSessionRow[Index-1u].DcmDspSessionP2StarServerMax;
   return  E_OK;
}
#define  DCM_STOP_SEC_CODE
#include "Dcm_MemMap.h"

/*************************************************************************/
/*
 * Brief               <Set the module support each protocol  link layer parameters ,which is in protocol control block>
 * ServiceId           <None>
 * Sync/Async          <Synchronous>
 * Reentrancy          <Reentrant>
 * Param-Name[in]      <NewSes:the Latest session status>
 * Param-Name[out]     <None>
 * Param-Name[in/out]  <None>
 * Return              <None>
 * PreCondition        <None>
 * CallByAPI           <APIName>
 */
/*************************************************************************/
#define  DCM_START_SEC_CODE
#include "Dcm_MemMap.h"
static FUNC(void,DCM_CODE)DslInternal_SetSesTimingValues(Dcm_SesCtrlType NewSes)
{
	uint32 P2ServerTimer;
	uint32 P2StarServerTimer;
    Std_ReturnType  ret;

    /*Get the new session configuration corresponding to the time parameters of Dsp module*/
    ret = DslInternal_GetSesTimingValues(NewSes,&P2ServerTimer,&P2StarServerTimer);
    if(E_NOT_OK == ret)
    {
        return;
    }
    /*set all protocols which are configured,corresponding link layer Time parameters of Dsl module*/
    DslInternal_SetProtocolLinkLayerTimer(P2ServerTimer,P2StarServerTimer);
}
#define  DCM_STOP_SEC_CODE
#include "Dcm_MemMap.h"

/*************************************************************************/
/*
 * Brief               <session change from default to default>
 * ServiceId           <None>
 * Sync/Async          <Synchronous>
 * Reentrancy          <Reentrant>
 * Param-Name[in]      <NewSes:the Latest session status>
 * Param-Name[out]     <None>
 * Param-Name[in/out]  <None>
 * Return              <None>
 * PreCondition        <>
 * CallByAPI           <APIName>
 */
/*************************************************************************/
#define  DCM_START_SEC_CODE
#include "Dcm_MemMap.h"
static FUNC(void,DCM_CODE)DslInternal_DefaultToDefault(Dcm_SesCtrlType NewSes)
{
    DslInternal_SetSesCtrlType(NewSes);

    DslInternal_SetSesTimingValues(NewSes);
   /************************************************************
    * The session state from the default to the default,
    * specific needs to be done temporarily unclear, to be added
    ************************************************************/
#if(STD_ON == DCM_SECURITY_FUNC_ENABLED)
    /****@req DCM-FUNR-031[DCM139]****/
    DslInternal_SetSecurityLevel(DCM_SEC_LEV_LOCKED);
    DslInternal_SetSecurityAccessStatus(DCM_SERVICE_IDLE);
#endif

}
#define  DCM_STOP_SEC_CODE
#include "Dcm_MemMap.h"

/*************************************************************************/
/*
 * Brief               <session change from default to undefault>
 * ServiceId           <None>
 * Sync/Async          <Synchronous>
 * Reentrancy          <Reentrant>
 * Param-Name[in]      <NewSes:the Latest session status>
 * Param-Name[out]     <None>
 * Param-Name[in/out]  <None>
 * Return              <None>
 * PreCondition        <>
 * CallByAPI           <APIName>
 */
/*************************************************************************/
#define  DCM_START_SEC_CODE
#include "Dcm_MemMap.h"
static FUNC(void,DCM_CODE) DslInternal_DefaultToUndefault(Dcm_SesCtrlType NewSes)
{
	NetworkHandleType NetworkChannel;
	uint8 Index;
	NetworkChannel  = Dcm_MkCtrl.Dcm_ActiveNetwork;

    SchM_Enter_Dcm(Dcm_SesCtrl);
    Dcm_SesCtrl.Dcm_SessionState = DCM_SESSION_UNDEFAULT;
    SchM_Exit_Dcm(Dcm_SesCtrl);

    DslInternal_SetSesCtrlType(NewSes);
    DslInternal_SetSesTimingValues(NewSes);
    /* Notice Comm module into "Full Communication" */

	#if(STD_ON == DCM_SECURITY_FUNC_ENABLED)
	/****SWS_Dcm_00139****/
		DslInternal_SetSecurityLevel(DCM_SEC_LEV_LOCKED);
		DslInternal_SetSecurityAccessStatus(DCM_SERVICE_IDLE);
	#endif

    /****@req DCM-FUNR-056[DCM167]****/
    for (Index = 0; Index < DCM_MAINCONNECTION_NUM; Index++)
    {
        if ((DCM_COMM_ACTIVE == Dcm_CommCtrl[Index].Dcm_ActiveDiagnostic)
            && (NetworkChannel == Dcm_CommCtrl[Index].DcmDslProtocolComMChannelId))
        {
            ComM_DCM_ActiveDiagnostic(NetworkChannel);
        }
    }
    /************************************************************
     * The session state from the default to the undefault,
     * specific needs to be done temporarily unclear, to be added
     ************************************************************/
}
#define  DCM_STOP_SEC_CODE
#include "Dcm_MemMap.h"

/*************************************************************************/
/*
 * Brief               <session change from undefault to undefault>
 * ServiceId           <None>
 * Sync/Async          <Synchronous>
 * Reentrancy          <Reentrant>
 * Param-Name[in]      <NewSes:the Latest session status>
 * Param-Name[out]     <None>
 * Param-Name[in/out]  <None>
 * Return              <None>
 * PreCondition        <>
 * CallByAPI           <APIName>
 */
/*************************************************************************/
#define  DCM_START_SEC_CODE
#include "Dcm_MemMap.h"
static FUNC(void,DCM_CODE)DslInternal_UndefaultToUndefault(Dcm_SesCtrlType NewSes)
{
    DslInternal_SetSesCtrlType(NewSes);
    DslInternal_SetSesTimingValues(NewSes);
#if(STD_ON == DCM_SECURITY_FUNC_ENABLED)
    /****@req DCM-FUNR-031[DCM139]****/
    DslInternal_SetSecurityLevel(DCM_SEC_LEV_LOCKED);
    DslInternal_SetSecurityAccessStatus(DCM_SERVICE_IDLE);
#endif
    /************************************************************
     * The session state from the undefault to the undefault,
     * specific needs to be done temporarily unclear, to be added
     ************************************************************/
}
#define  DCM_STOP_SEC_CODE
#include "Dcm_MemMap.h"

/*************************************************************************/
/*
 * Brief               <session change from undefault to default>
 * ServiceId           <None>
 * Sync/Async          <Synchronous>
 * Reentrancy          <Reentrant>
 * Param-Name[in]      <NewSes:the Latest session status>
 * Param-Name[out]     <None>
 * Param-Name[in/out]  <None>
 * Return              <None>
 * PreCondition        <None>
 * CallByAPI           <APIName>
 */
/*************************************************************************/
#define  DCM_START_SEC_CODE
#include "Dcm_MemMap.h"
static FUNC(void,DCM_CODE)DslInternal_UndefaultTodefault(Dcm_SesCtrlType NewSes)
{
    NetworkHandleType NetworkChannel;

    NetworkChannel = Dcm_MkCtrl.Dcm_ActiveNetwork;

	SchM_Enter_Dcm(Dcm_SesCtrl);
    Dcm_SesCtrl.Dcm_SessionState = DCM_SESSION_DEFAULT;
    SchM_Exit_Dcm(Dcm_SesCtrl);

    /****SWS_Dcm_00022****/
    DslInternal_SetSesCtrlType(NewSes);
    DslInternal_SetSesTimingValues(NewSes);
    
#if(STD_ON == DCM_SECURITY_FUNC_ENABLED)
    /****SWS_Dcm_00139****/
    DslInternal_SetSecurityLevel(DCM_SEC_LEV_LOCKED);
    DslInternal_SetSecurityAccessStatus(DCM_SERVICE_IDLE);
#endif

#if((STD_ON == DCM_UDS_FUNC_ENABLED) && (STD_ON == DCM_UDS_SERVICE0X85_ENABLED))
    /*The update of the DTC status will be re-enabled*/
    Rte_EnableAllDtcsRecord();
#endif

#if((STD_ON == DCM_UDS_FUNC_ENABLED) && (STD_ON == DCM_UDS_SERVICE0X28_ENABLED ))
#if(BSWM_DCM_ENABLE == STD_ON)
	BswM_Dcm_CommunicationMode_CurrentState(NetworkChannel,DCM_ENABLE_RX_TX_NORM_NM);
#else
	Rte_DcmControlCommunicationMode(NetworkChannel,DCM_ENABLE_RX_TX_NORM_NM);
#endif
#endif
    /*Notice Comm Module exit "Full Communication"*/
    /****SWS_Dcm_00168****/
    ComM_DCM_InactiveDiagnostic(NetworkChannel);
    /************************************************************
     * The session state from the undefault to the default,
     * specific needs to be done temporarily unclear, to be added
     ************************************************************/
}
#define  DCM_STOP_SEC_CODE
#include "Dcm_MemMap.h"

/*************************************************************************/
/*
 * Brief               <When the session is changed, the specific processing>
 * ServiceId           <None>
 * Sync/Async          <Synchronous>
 * Reentrancy          <Reentrant>
 * Param-Name[in]      <NewSes:the Latest session status>
 * Param-Name[out]     <None>
 * Param-Name[in/out]  <None>
 * Return              <None>
 * PreCondition        <>
 * CallByAPI           <APIName>
 */
/*************************************************************************/
#define  DCM_START_SEC_CODE
#include "Dcm_MemMap.h"
static FUNC(void,DCM_CODE) DslInternal_SesTranslation(Dcm_SesCtrlType NewSes)
{
    if(DCM_SESSION_DEFAULT == Dcm_SesCtrl.Dcm_SessionState)
    {
        if(DCM_DEFAULT_SESSION == NewSes)
        {
            /*from the default session to the default session */
            DslInternal_DefaultToDefault(NewSes);
        }
        else
        {
            /*from the default session to the undefault session */
            DslInternal_DefaultToUndefault(NewSes);
        }
    }
    else
    {
        if(DCM_DEFAULT_SESSION == NewSes)
        {
            /*from the undefault session to the default session */
            DslInternal_UndefaultTodefault(NewSes);
        }
        else
        {
            /*from the undefault session to the undefault session */
            DslInternal_UndefaultToUndefault(NewSes);
        }
    }
}
#define  DCM_STOP_SEC_CODE
#include "Dcm_MemMap.h"

#endif
